
#delimit;

set more off;

capture log close;


drop _all;

local t2="specify here the folder path where the data are stored";
local t1="specify here the folder path where you want the output data to be stored";


**This do-file allows you to replicate the results from Tables 1, 2, 3 and upper panel of Table 44 (all results for the cross-section sample from Wave 2);

log using `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231.log, replace;
drop _all;

set mem 600m;

use `t2'w1rel231_w2rel231_ext; 

*Panel;
sort mergeid wave;

drop if age>=2005;



*I classify individuals depending on number of waves;
egen nwave=sum(wave), by (mergeid);
sort mergeid wave;


gen tipo=1 if nwave==1; 
*Only in 2004;
replace tipo=3 if nwave==3; 
*Both olas;
replace tipo=2 if nwave==2 ;
*drop if mergeid==mergeid[_n-1] & wave==wave[_n-1]+1;


forvalues c=11(1)20{;

           
          display "country==`c'";
         tab tipo if  country==`c';
          
         
             };
tab tipo if country==23;

tab country tipo;
*Longitudinals are in both waves;
*keep if tipo==3;*Only longitudinales;


tab wave;
encode mergeid, gen(mergeid1);
xtset mergeid1 wave, delta(1);
gen gender1= gender;
tab gender1 if wave==1;
tab gender1 if wave==2;


gen midage=(age>=50 & age<=60);
tab midage if gender1==1;
tab midage if gender1==2;

*gen sampid=substr(person,1,11);
gen sampid=hhid;
sort sampid wave mergeid;

gen id=1 in 1;
replace id=id[_n-1]+1 in 2/l;

gen id1=id;
replace id1=id[_n-1] if sampid==sampid[_n-1] & wave==wave[_n-1] & cvidp==cvid[_n-1] & cvid==cvidp[_n-1]; 
*id1 is different for every single individual and couple;



egen nchild2=sum(ch001), by (id1);

*Natural parents alive;

*Computing whether they have father or mother;
sort mergeid wave;

drop if wave==1 & ((dn026_1==-2) | (dn026_2==-2));
drop if wave==2 & ((dn026_1==-2) | (dn026_2==-2));

gen mother=1 if (dn026_1==1);
replace mother=0 if dn026_1==5 | dn026_1==-1;
replace mother=1 if wave==1 & dn026_1==. & ((cvid==1 & relrpers2==5 & ppgender==2) | (cvid==2 & relrpers2==6 & ppgender==2)
| (cvid==1 & relrpers2b==5 & ppgender2==2) | (cvid==2 & relrpers2b==6  & ppgender2==2)); 
replace mother=1 if wave==2 & dn026_1==. & ((cvid==1 & relrpers2==5 & ppgender==2) | (cvid==2 & relrpers2==6 & ppgender==2)
| (cvid==1 & relrpers2b==5 & ppgender2==2) | (cvid==2 & relrpers2b==6  & ppgender2==2)); 

gen father=1 if (dn026_2==1);
replace father=0 if (dn026_2==5) | dn026_2==-1;
replace father=1 if wave==1 & dn026_2==. & ((cvid==1 & relrpers2==5 & ppgender==1) | (cvid==2 & relrpers2==6 & ppgender==1)
| (cvid==1 & relrpers2b==5 & ppgender2==1) | (cvid==2 & relrpers2b==6  & ppgender2==1)); 
replace father=1 if wave==2 & dn026_2==. & ((cvid==1 & relrpers2==5 & ppgender==1) | (cvid==2 & relrpers2==6 & ppgender==1)
| (cvid==1 & relrpers2b==5 & ppgender2==1) | (cvid==2 & relrpers2b==6  & ppgender2==1)); 

sort mergeid1 wave;
gen lmother=L.mother if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];
gen ldn026_1=L.dn026_1 if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];
gen lfather=L.father if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];
gen ldn026_2=L.dn026_2 if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];
gen lep005_=L.ep005_ if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];
gen lisced_r=L.isced_r if tipo==3 & wave==2 & mergeid1==mergeid1[_n-1];




*Same for wave 2;
replace mother=0 if mother==. & ldn026_1==5 & wave==2;
*Missings in W2 because they reported in W1 that they did not have parents alive;
replace father=0 if father==. & ldn026_2==5 & wave==2;

drop if mother==. & ldn026_1!=5 & wave==2 & tipo==3; 
*Missing info
drop if mother==. & wave==2 & tipo!=3; 
drop if father==. & ldn026_2!=5 & wave==2 & tipo==3;
drop if father==. & wave==2 & tipo!=3; 

replace nchild2=nchild if wave==1;
replace nchild2=nchild2[_n-1] if wave==2 & tipo==3 & mergeid1==mergeid1[_n-1];

gen dn014_b=dn014_ if wave==1;
replace dn014_b=dn014_ if wave==2;
replace dn014_b=dn014_[_n-1] if wave==2 & tipo==3 & mergeid1==mergeid1[_n-1] & dn014_==.;


drop if wave==1; 
**Keep individuals in Wave 2;
drop if gender==1; 
*Keep women;
drop if midage==0;  
*Keep women between 50 and 60;



*Age father/mother;
gen mage=dn028_1;
replace mage=ppage if dn026_1==. & mother==1;
replace mage=ppage2 if dn026_1==. & mother==1 & ppage==0;

gen fage=dn028_2;
replace fage=ppage if dn026_2==. & father==1;
replace fage=ppage2 if dn026_2==. & father==1 & ppage==0;

*Health status father/mother;
gen mhealth=dn033_1;
replace mhealth=pphealth if dn026_1==. & mother==1;
replace mhealth=pphealth2 if dn026_1==. & mother==1 & pphealth==0;
replace mhealth=0 if mother==0;


gen fhealth=dn033_2;
replace fhealth=pphealth if dn026_2==. & father==1;
replace fhealth=pphealth2 if dn026_2==. & father==1 & pphealth==0;
replace fhealth=0 if father==0;

drop if mhealth==-1 | mhealth==-2 | fhealth==-1 | fhealth==-2 | mhealth==. | fhealth==.;



*Rescaling of US (wave2) and UE (wave1) versions of parental health;
gen mhealth2=1 if (mhealth==1 | mhealth==2) & wave==2;
replace mhealth2=2 if mhealth==3 & wave==2;
replace mhealth2=3 if mhealth==4 & wave==2;
replace mhealth2=4 if mhealth==5 & wave==2;
replace mhealth2=0 if mhealth==0;

gen fhealth2=1 if (fhealth==1 | fhealth==2) & wave==2;
replace fhealth2=2 if fhealth==3 & wave==2;
replace fhealth2=3 if fhealth==4 & wave==2;
replace fhealth2=4 if fhealth==5 & wave==2;
replace fhealth2=0 if fhealth==0;

drop phealth;
gen phealth=mhealth2 if (mother==1 & father==0);
replace phealth=fhealth2 if (mother==0 & father==1);
replace phealth=mhealth2 if (mother==1 & father==1) & mhealth2>fhealth2;
replace phealth=fhealth2 if (mother==1 & father==1) & mhealth2<fhealth2;
replace phealth=fhealth2 if (mother==1 & father==1) & mhealth2==fhealth2;
replace phealth=0 if mother==0 & father==0;


gen parent=(mother==1 | father==1);
gen parent1=(dn026_1==1 | dn026_2==1); 
gen nparent=2 if mother==1 & father==1;
replace nparent=0 if mother==0 & father==0;
replace nparent=1 if nparent==.;

gen lparent=L.parent;
gen lnparent=L.nparent;


drop if parent==0; 
**Drop if they do not have any living father/mother;




*Caregiving;
drop if (sp008==-1 | sp008==-2 | sp008==.);
drop if (sp018==-1 | sp018==-2);
drop if (sp009_1==-1 | sp009_1==-2) | (sp009_2==-1 | sp009_2==-2) | (sp009_3==-1 | sp009_3==-2);
drop if (sp011_1==-1 | sp011_1==-2) | (sp011_2==-1 | sp011_2==-2) | (sp011_3==-1 | sp011_3==-2);
*drop if sp019_1==-2 | sp019_2==-2 | sp019_3==-2;
*drop if sp019_1==-1 | sp019_2==-1 | sp019_3==-1;

*drop if sp019drf==1;
*drop if sp019ddk==1;

*Caregiving to parents outside the HH;
gen carerpo=(( sp009_1==2 | sp009_1==3));
replace carerpo=1 if (( sp009_2==2 | sp009_2==3) );
replace carerpo=1 if (( sp009_3==2 | sp009_3==3) );


*Caregiving to parents inside the HH;
gen carerpi=(( sp019d2==1 | sp019d3==1) & wave==1);
*gen carerpi=((( sp019_1==2 | sp019_1==3)| ( sp019_2==2 | sp019_2==3)| ( sp019_3==2 | sp019_3==3)) & wave==2);

replace carerpi=((sp019d2==1 | sp019d3==1) & wave==2);

gen carerp=(carerpo==1 | carerpi==1);

*Intensive Caregiving to parents;
gen atweek1=1 if carerpi==1; 
replace atweek1=1 if (sp008==1  & (sp009_1==2 | sp009_1==3) & (sp011_1==2 | sp011_1==1));
replace atweek1=1 if (sp008==1  & (sp009_2==2 | sp009_2==3) & (sp011_2==2 | sp011_2==1));
replace atweek1=1 if (sp008==1  & (sp009_3==2 | sp009_3==3) & (sp011_3==2 | sp011_3==1));
replace atweek1=0 if atweek1==.;

gen daily=1 if carerpi==1; 
replace daily=1 if (sp008==1  & (sp009_1==2 | sp009_1==3) & ( sp011_1==1));
replace daily=1 if (sp008==1  & (sp009_2==2 | sp009_2==3) & ( sp011_2==1));
replace daily=1 if (sp008==1  & (sp009_3==2 | sp009_3==3) & ( sp011_3==1));
replace daily=0 if daily==.;

*Less than intensive;
gen lsweek1=(carerp==1 & atweek1==0);




*Employment. Hours of work; 

drop if (ep005_==. | ep005_==-1 | ep005_==-2) & wave==2; 
*Missing values in Nursing homes;
*drop if (ep002_==-2 | ep002_==-1) & wave==2;

gen ep013b=ep013_ if wave==2;
replace ep013b=0 if ep013b==. & wave==2;
gen worker=1 if ep013b>0 & wave==2; 
replace worker=0 if ep005_!=2 & ep125!=1 & wave==2; 
replace worker=0 if (worker==.) & wave==2;

**Alternative definition of workers;
gen worker1=(ep005_==2 );
gen worker2=(ep005_==2 | ep002_==1);


*Country Grouping;
gen group=1 if (country==13 | country==14 | country==18);
replace group=2 if (country==11 | country==12 | country==17 | country==20 | country==23);
replace group=3 if (country==15 | country==16 | country==19);


tab group gender1 if wave==2;


*An�lisis;
tab country if gender1==2 & wave==1;



gen ivphealth=(phealth==4); 
**This is our main instrument;
gen ivphealthg=(phealth==1 | phealth==2);
gen ivphealthf=(phealth==3);



**Controls;
gen age5055=(age>=50 & age<=55) if wave==2;
gen age5660=(age>=56 & age<=60) if wave==2;
drop if age<0;
gen age1=age/10;
gen age12=age1^2;

*Education Dummies;
gen educ1=(edu==0 | edu==1);
gen educ2=(edu==2);
gen educ3=(edu==3);
gen educ4=(edu==4 | edu==5 | edu==6);
drop if edu==97;

drop if (ph003==-2 | ph003==-1) & wave==2;
gen spheuvg=((ph003==1 | ph003==2 | ph003==3) & wave==2);
gen spheuvg2=((ph003==1 | ph003==2) & wave==2);
gen spheug=(ph003==3 & wave==2);
gen spheuf=(ph003==4 & wave==2);
gen spheub=(ph003==5 & wave==2);
gen spheufb=((spheuf==1 | spheub==1) & wave==2);


gen austria=(country==11);
gen germany=(country==12);
gen sweden=(country==13);
gen netherlands=(country==14);
gen spain=(country==15);
gen italy=(country==16);
gen france=(country==17);
gen denmark=(country==18);
gen greece=(country==19);
gen switz=(country==20);
gen belgium=(country==23);


gen married=(dn014_b==1 | dn014_b==2); 



gen nli=(hgtincv-ydipv-yindv)/(pppx2005*1000);
gen sisters=dn037;
replace sisters=0 if (dn037==. | dn037==0 | dn037==-1);
gen brothers=dn036;
replace brothers=0 if (dn036==. | dn036==0 | dn036==-1);
drop if sisters==-2 | brothers==-2;
drop if nchild2==.;

**Hours of care to elderly parents;
gen hours_care1=sp012_1*7 if sp011_1==1;
replace hours_care1=sp012_1 if sp011_1==2;
replace hours_care1=sp012_1/(52/12) if sp011_1==3;
replace hours_care1=sp012_1/(52) if sp011_1==4;

gen hours_care2=sp012_2*7 if sp011_2==1;
replace hours_care2=sp012_2 if sp011_2==2;
replace hours_care2=sp012_2/(52/12) if sp011_2==3;
replace hours_care2=sp012_2/(52) if sp011_2==4;

gen hours_care3=sp012_3*7 if sp011_3==1;
replace hours_care3=sp012_3 if sp011_3==2;
replace hours_care3=sp012_3/(52/12) if sp011_3==3;
replace hours_care3=sp012_3/(52) if sp011_3==4;

gen h_c1=hours_care1 if (sp009_1==2 | sp009_1==3) & (sp011_1==1 | sp011_1==2);
replace h_c1=0 if h_c1==.;
gen h_c2=hours_care2 if (sp009_2==2 | sp009_2==3) & (sp011_2==1 | sp011_2==2);
replace h_c2=0 if h_c2==.;
gen h_c3=hours_care3 if (sp009_3==2 | sp009_3==3) & (sp011_3==1 | sp011_3==2);
replace h_c3=0 if h_c3==.;
gen h_c=h_c1+h_c2+h_c3;


tab group wave if gender==2;
tab sp012_1 if gender==2 & (sp009_1==2 | sp009_1==3) & (sp011_1==1 | sp011_1==2);
tab sp012_2 if gender==2 & (sp009_2==2 | sp009_2==3) & (sp011_2==1 | sp011_2==2);
tab sp012_3 if gender==2 & (sp009_3==2 | sp009_3==3) & (sp011_3==1 | sp011_3==2);



gen hw=ep013b if wave==2;
tab ep013_ if gender==2 & worker==1 & wave==2;



drop if ep005_==4;
drop if ep005_==4 | ep005_==1; 
**We drop retired and permanently disabled people;

gen resident=(dn030_1==1 | dn030_2==1 );
replace resident=1 if wave==2 & dn026_1==. & ((cvid==1 & relrpers2==5 & ppgender==2) | (cvid==2 & relrpers2==6 & ppgender==2)
| (cvid==1 & relrpers2b==5 & ppgender2==2) | (cvid==2 & relrpers2b==6  & ppgender2==2));
replace resident=1 if wave==2 & dn026_2==. & ((cvid==1 & relrpers2==5 & ppgender==1) | (cvid==2 & relrpers2==6 & ppgender==1)
| (cvid==1 & relrpers2b==5 & ppgender2==1) | (cvid==2 & relrpers2b==6  & ppgender2==1)); 

**Resident corresponds to coresidents and resident2 to women with at least one parent living outside the household but less than 5 kms away;
gen resident1=(dn030_1<=4 | dn030_2<=4 | resident==1);
gen resident2=((dn030_1<=4 & dn030_1>=2) | (dn030_2<=4 & dn030_2>=2));

gen both=(mother==1 & father==1);


**RESULTS;

**Descriptives: Results in Table 3 and upper panel in Table 1;
sum worker1 daily atweek1 carerp age1 educ1 educ2 educ3 educ4 nli married nchild2 spheuvg2 spheug spheuf spheub brothers sisters ivphealth resident resident1 resident2 if group==1;
sum worker1 daily atweek1 carerp age1 educ1 educ2 educ3 educ4 nli married nchild2 spheuvg2 spheug spheuf spheub brothers sisters ivphealth resident resident1 resident2 if group==2;
sum worker1 daily atweek1 carerp age1 educ1 educ2 educ3 educ4 nli married nchild2 spheuvg2 spheug spheuf spheub brothers sisters ivphealth resident resident1 resident2 if group==3;

**Descriptives: Results in Table 1 (intermediate panel);
sum atweek1 daily if carerp==1 & group==1;
sum atweek1 daily if carerp==1 & group==2;
sum atweek1 daily if carerp==1 & group==3;

**Descriptives: Results in Table 1 (bottom panel);
sum daily if carerp==1 & group==1 & atweek1==1;
sum daily if carerp==1 & group==2 & atweek1==1;
sum daily if carerp==1 & group==3 & atweek1==1;

**Descriptives: Results in Table 2;
tab worker1 daily if group==1, col;
tab worker1 daily if group==2, col;
tab worker1 daily if group==3, col;
				
**Results Table 4 (top panel): Cross-section 2006, no controls, Wald estimate;
**Caregiving effect (denominator);
forvalues c=1(1)3{;
          display "group==`c' gender1==2";
         reg daily ivphealth if  wave==2 & group==`c' & gender1==2, rob;          

		 };
**Employment effect (numerator);
		 forvalues c=1(1)3{;
          display "group==`c' gender1==2";
         reg worker1 ivphealth if  wave==2 & group==`c' & gender1==2, rob;
				 };



				
				
**Non-parametric estimators;
**This is the dummy of education that we use in the regressions;
gen educ=(educ1==1 | educ2==1);

**propensity scores for the instrument z;
probit ivphealth age1 educ sisters if wave==2 & gender1==2 & group==1, rob;
predict prn2;
probit ivphealth age1 educ sisters if wave==2 & gender1==2 & group==2, rob;
predict prc2;
probit ivphealth age1 educ sisters if wave==2 & gender1==2 & group==3, rob;
predict prs2;


sum prn2 if wave==2 & gender1==2 & group==1 & ivphealth==1;
sum prn2 if wave==2 & gender1==2 & group==1 & ivphealth==0;
sum prc2 if wave==2 & gender1==2 & group==2 & ivphealth==1;
sum prc2 if wave==2 & gender1==2 & group==2 & ivphealth==0;
sum prs2 if wave==2 & gender1==2 & group==3 & ivphealth==1;
sum prs2 if wave==2 & gender1==2 & group==3 & ivphealth==0;


**Results Table 4: Cross-section 2006, controls, weighting estimator (SEs are computed by bootstrap in the corresponding files);
**Employment effect (numerator);
gen numi2=((worker1*ivphealth)/prn2)-((worker1*(1-ivphealth))/(1-prn2)) if gender1==2 & wave==2 & group==1;
sum numi2 if gender1==2 & wave==2 & group==1, det;
gen num2=r(mean) if gender1==2 & wave==2 & group==1;
replace numi2=((worker1*ivphealth)/prc2)-((worker1*(1-ivphealth))/(1-prc2)) if gender1==2 & wave==2 & group==2;
sum numi2 if gender1==2 & wave==2 & group==2, det;
replace num2=r(mean) if gender1==2 & wave==2 & group==2;
replace numi2=((worker1*ivphealth)/prs2)-((worker1*(1-ivphealth))/(1-prs2)) if gender1==2 & wave==2 & group==3;
sum numi2 if gender1==2 & wave==2 & group==3, det;
replace num2=r(mean) if gender1==2 & wave==2 & group==3;

**Caregiving effect (denominator);
gen denomi2=((daily*ivphealth)/prn2)-((daily*(1-ivphealth))/(1-prn2)) if gender1==2 & wave==2 & group==1;
sum denomi2 if gender1==2 & wave==2 & group==1, det;
gen denom2=r(mean) if gender1==2 & wave==2 & group==1;
replace denomi2=((daily*ivphealth)/prc2)-((daily*(1-ivphealth))/(1-prc2)) if gender1==2 & wave==2 & group==2;
sum denomi2 if gender1==2 & wave==2 & group==2, det;
replace denom2=r(mean) if gender1==2 & wave==2 & group==2;
replace denomi2=((daily*ivphealth)/prs2)-((daily*(1-ivphealth))/(1-prs2)) if gender1==2 & wave==2 & group==3;
sum denomi2 if gender1==2 & wave==2 & group==3, det;
replace denom2=r(mean) if gender1==2 & wave==2 & group==3;


gen late=num2/denom2;
sum late if gender1==2 & wave==2 & group==3, det;





sort mergeid;
save `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231, replace;

**We just keep variables for employment status, intensive caregiving, having at least one parent in bad health, age, level of education, number of sisters, country to be used in the computation of
**the SEs;
use `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231;
keep if group==1 & wave==2 & gender==2;
keep worker1 daily ivphealth age1 educ sisters country;
save `t1'north_w1w2_2006_w2rel231_w1rel231, replace;
use `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231;
keep if group==2 & wave==2 & gender==2;
keep worker1 daily ivphealth age1 educ sisters country;
save `t1'cont_w1w2_2006_w2rel231_w1rel231, replace;
use `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231;
keep if group==3 & wave==2 & gender==2;
keep worker1 daily ivphealth age1 educ sisters country;
save `t1'sout_w1w2_2006_w2rel231_w1rel231, replace;


use `t1'sampleFRB_w1w2_ext_cross06_w2rel231_w1rel231;

log close;

**Results in the online Appendix: Table A1.1.
**Analysis of hours of work and weekly hours of informal care outside the household for our sample of interest;
**HOURS OF INFORMAL CARE TO A PERSON LIVING OUTSIDE THE HOUSEHOLD;
**WEEKLY HOURS OF WORK;

gen daily_out=(sp008==1  & (sp009_1==2 | sp009_1==3) & sp011_1==1);
replace daily_out=1 if (sp008==1  & (sp009_2==2 | sp009_2==3) & ( sp011_2==1));
replace daily_out=1 if (sp008==1  & (sp009_3==2 | sp009_3==3) & ( sp011_3==1));
replace daily_out=0 if daily_out==.;

gen atweek1_out=(sp008==1  & (sp009_1==2 | sp009_1==3) & (sp011_1==1 | sp011_1==2));
replace atweek1_out=1 if (sp008==1  & (sp009_2==2 | sp009_2==3) & (sp011_2==1 | sp011_2==2));
replace atweek1_out=1 if (sp008==1  & (sp009_3==2 | sp009_3==3) & (sp011_3==1 | sp011_3==2));
replace atweek1_out=0 if atweek1_out==.;


list daily daily_out if (sp012_1==-1 | sp012_1==-2) & gender==2 & (sp009_1==2 | sp009_1==3) & (sp011_1==1);
list daily daily_out if (sp012_2==-1 | sp012_2==-2) & gender==2 & (sp009_2==2 | sp009_2==3) & (sp011_2==1);
list daily daily_out if (sp012_3==-1 | sp012_3==-2) & gender==2 & (sp009_3==2 | sp009_3==3) & (sp011_3==1);

drop if (sp012_1==-1 | sp012_1==-2) & gender==2 & (sp009_1==2 | sp009_1==3) & (sp011_1==1);
drop if (sp012_2==-1 | sp012_2==-2) & gender==2 & (sp009_2==2 | sp009_2==3) & (sp011_2==1);
drop if (sp012_3==-1 | sp012_3==-2) & gender==2 & (sp009_3==2 | sp009_3==3) & (sp011_3==1);

list atweek1 atweek1_out if (sp012_1==-1 | sp012_1==-2) & gender==2 & (sp009_1==2 | sp009_1==3) & (sp011_1==1 | sp011_1==2);
list atweek1 atweek1_out if (sp012_2==-1 | sp012_2==-2) & gender==2 & (sp009_2==2 | sp009_2==3) & (sp011_2==1 | sp011_2==2);
list atweek1 atweek1_out if (sp012_3==-1 | sp012_3==-2) & gender==2 & (sp009_3==2 | sp009_3==3) & (sp011_3==1 | sp011_3==2);

drop if (sp012_1==-1 | sp012_1==-2) & gender==2 & (sp009_1==2 | sp009_1==3) & (sp011_1==1 | sp011_1==2);
drop if (sp012_2==-1 | sp012_2==-2) & gender==2 & (sp009_2==2 | sp009_2==3) & (sp011_2==1 | sp011_2==2);
drop if (sp012_3==-1 | sp012_3==-2) & gender==2 & (sp009_3==2 | sp009_3==3) & (sp011_3==1 | sp011_3==2);

drop if (ep013_==-1 | ep013_==-2) & gender==2 & worker1==1 & wave==2;

sum h_c if gender==2 & wave==2 & daily_out==1  & group==1, det;
sum h_c if gender==2 & wave==2 & daily_out==1 & group==2, det;
sum h_c if gender==2 & wave==2 & daily_out==1  & group==3, det;

kdensity h_c if gender==2 & wave==2 & daily_out==1 & group==1;
graph save `t1'care_nc_w2, replace;

kdensity h_c if gender==2 & wave==2 & daily_out==1  & group==2 ;
graph save `t1'care_cc_w2, replace;

kdensity h_c if gender==2 & wave==2 & daily_out==1 & group==3 ;
graph save `t1'care_sc_w2, replace;
gr combine `t1'care_sc_w2.gph `t1'care_nc_w2.gph `t1'care_cc_w2.gph, ycommon xcommon;


sum hw if gender==2 & wave==2 & worker1==1 & group==1, det;
sum hw if gender==2 & wave==2 & worker1==1 & group==2, det;
sum hw if gender==2 & wave==2 & worker1==1 & group==3, det;

kdensity hw if gender==2 & wave==2 & worker1==1 & group==1;
graph save `t1'work_nc_w2, replace;

kdensity hw if gender==2 & wave==2 & worker1==1 & group==2;
graph save `t1'work_cc_w2, replace;

kdensity hw if gender==2 & wave==2 & worker1==1 & group==3;
graph save `t1'work_sc_w2, replace;
gr combine `t1'work_sc_w2.gph `t1'work_nc_w2.gph `t1'work_cc_w2.gph, ycommon xcommon;


			 

log close;
